
import 'dart:ui';

class FMColorTool {

  static Color color(String colorValueString, {double alpha = 1.0}) {

    String colorString = colorValueString;

    if (!colorString.startsWith('0xff') && colorString.length == 6) {
      colorString = '0xff$colorString';
    }
    if(colorString.startsWith('0x') && colorString.length == 8) {
      colorString = colorString.replaceRange(0, 2, '0xff');
    }
    if(colorString.startsWith('#') && colorString.length == 7) {
      colorString = colorString.replaceRange(0, 1, '0xff');
    }
    // 先分别获取色值的RGB通道
    Color color = Color(int.parse(colorString));
    int red = color.red;
    int green = color.green;
    int blue = color.blue;

    return Color.fromRGBO(red, green, blue, alpha);
  }
  
  static get blackColor {
    return color("#333333");
  }
}